<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$webtitle}</title>
    
    <link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/news/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="__STATIC__/news/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">

    <!-- Data Tables -->
    <link href="__STATIC__/news/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/bootstrap-datetimepicker.min.css">
    <link href="__STATIC__/news/css/animate.min.css" rel="stylesheet">
    <link href="__STATIC__/news/css/style.min.css?v=4.0.0" rel="stylesheet">
    <script src="http://www.jq22.com/jquery/1.11.1/jquery.min.js"></script>
    

    <style type="text/css">
    th{
        text-align: center;
    }
   
    .box1{
        right: 10px;
        width: 20px;
        height: 25px;
    }
   
    </style>
    <body class="gray-bg">
    
<div class="wrapper wrapper-content animated fadeInRight">

<div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <!-- <div class="ibox-title">
                        <h5>权限管理</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div> -->
                    <a href="#" class="btn btn-primary add">新增人员</a>
                    <a href="#" class="btn btn-info" onclick="edit()">修改</a>
                    <a href="#" class="btn btn-danger" onclick="del()">删除</a>
                    <!-- <a href="#" class="btn btn-success" onclick="distributionRole()">权限分配</a> -->
                    <div class="ibox-content">
                        <table  class="table table-striped table-bordered table-hover dataTables-example" id="example">
                            <thead>
                                <tr>
                                    <th><input type="checkbox" name="all" id='all' class="box1"></th>
                                    <th>职工姓名</th>
                                    <th>联系方式</th>
                                    <th>账号</th>
                                    <th>密码</th>
                                    <th>角色</th>
                                    <th>创建者</th>
                                    <th>最近登录时间</th>
                                    <th>创建时间</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach($info as $k=>$val):?>
                                <tr class="gradeX">
                                    <td><input type="checkbox" name="one" value="{$val.id}" class="box1"></td>
                                    <td>{$val.truename}</td>
                                    <td>{$val.mobile}</td>
                                    <td>{$val.name}</td>
                                    <td>{$val.password}</td>
                                    <td>{$val.role_name}</td>
                                    <td>{$val.creater}</td>
                                    <td>{$val.lastlogin|date="Y-m-d",###}</td>
                                    <td>{$val.createtime|date="Y-m-d",###}</td>
                                </tr>
                                <?php endforeach;?>
                            </tbody> 
                        </table>
                    </div>
                </div>
            </div>
        </div>
        </div>

<script src="__STATIC__/news/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/news/js/bootstrap.min.js?v=3.3.5"></script>
<script src="__STATIC__/news/js/plugins/jeditable/jquery.jeditable.js"></script>
<script src="__STATIC__/news/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="__STATIC__/news/js/plugins/dataTables/dataTables.bootstrap.js"></script>
<script src="__STATIC__/news/js/content.min.js?v=1.0.0"></script>
<script type="text/javascript" src="__STATIC__/js/layer/layer.js"></script>
<script type="text/javascript" src="__STATIC__/js/bootstrap-datetimepicker.min.js"></script>
<script src="__STATIC__/components/layui/layui/layui.all.js"></script>
<!-- 分页插件 -->
<script type="text/javascript">
    $(document).ready(function() {
        var table=$('#example').DataTable( {
            "ordering": false,//禁止排序
            // "aaSorting": [[ 3, "desc" ]],//设定第几行排序
            "language": {
                "sProcessing": "处理中...",
                "sLengthMenu": "显示 _MENU_ 项结果",
                "sZeroRecords": "没有匹配结果",
                "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                "sInfoPostFix": "",
                "sSearch": "搜索:",
                "sUrl": "",
                "sEmptyTable": "表中数据为空",
                "sLoadingRecords": "载入中...",
                "sInfoThousands": ",",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页"
                },
                // "oAria": {
                //     "sSortAscending": ": 以升序排列此列",
                //     "sSortDescending": ": 以降序排列此列"
                // }
            },
        });
    })

    //全选反选
    $('#all').click(function(){
         $("input[name='one']").prop("checked", this.checked); 
        
    })
    //获取被选中的id
    function get_ids_checked(){
      obj = document.getElementsByName("one");
          check_val = [];
          for(k in obj){
              if(obj[k].checked)
                  check_val.push(obj[k].value);
          }
          return check_val;
          alert(check_val);
          
    }
    //编辑
    function edit(){
      ids = get_ids_checked();
      if(ids == ''){
        alert('请先选择数据哦!!');return false;
      }
      if(ids.length > 1){
        alert('只能对单条数据进行修改哦!');return false;
      }
      $.ajax({
          url:"{:U('System/return_admin_user_info')}",
          data:{admin_id:ids},
          type:"POST",
          dataType:"json",
          success:function(ret){
            layui.use('layer', function(){
              var layer = layui.layer;
              layer.open({
                type: 2,
                title: ['修改', 'font-size:18px;'],
                closeBtn: 1,
                shadeClose: true,
                skin: 'add_form',
                area: ['60%','80%'],
                // offset: ['20%', '12%'],
                content: ["{:U('System/add_edit_user_index')}?admin_id="+ret],
                cancel: function(index, layero){ 
                  layer.close('add_edit_user_index');
                  location.reload();
                }   
              });
            });
          }
      })
    }

    //新增
    $('.add').click(function(){
        layui.use('layer', function(){
          var layer = layui.layer;
          layer.open({
            type: 2,
            title: ['新增', 'font-size:18px;'],
            closeBtn: 1,
            shadeClose: true,
            skin: 'add_form',
            area: ['60%','80%'],
            // offset: ['20%', '12%'],
            content: ["{:U('System/add_edit_user_index')}"],
            cancel: function(index, layero){ 
              layer.close('add_edit_user_index');
              location.reload();
            } 
          });
        });
    })

    //分配权限
    function distributionRole(){
        ids = get_ids_checked();
        if(ids == ''){
          alert('请先选择数据哦!!');return false;
        }
        if(ids.length > 1){
          alert('只能对单条数据进行修改哦!');return false;
        }
        var index = layer.open({
          type: 2,
          title: ['权限分配', 'font-size:18px;'],
          content: ["{:U('System/distributionRole')}?role_id="+ids],
          area: ['320px', '195px'],
          maxmin: true
        });
        layer.full(index);
    }

    //删除
    function del(){
        ids = get_ids_checked();
        if(ids == ''){
          alert('请先选择数据哦!!');return false;
        }
        $.ajax({
            url:"{:U('System/del_user')}",
            data:{ids:ids},
            type:'POST',
            dataType:'json',
            success:function(res){
                layer.msg('删除成功');
                location.reload();
            }
        })
    }
</script>
 </html>